home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $YoungMath < prev    next >
Encoding:
Text File  |  1991-11-23  |  629 b   |  33 lines  |  [TEXT/KEEN]

  1. #$YoungMath
  2.  
  3. BEGIN {    basicPrompt = "What is the sum of "
  4.         do
  5.             {
  6.             oldX = x
  7.             oldY = y
  8.             x = int(1000*rand()) + 1
  9.             y = int(1000*rand()) + 1
  10.             if (numAsked)
  11.                 {
  12.                 sum = oldX + oldY
  13.                 if (answer+0 != sum)
  14.                     {
  15.                     response = "Sorry, the real sum is " sum "\n"
  16.                     }
  17.                 else
  18.                     {
  19.                     ++numRight
  20.                     response = "Right!\n"
  21.                     }
  22.                 }
  23.             answer = prompt(response basicPrompt x " and " y "?")
  24.             ++numAsked;
  25.             } while (answer != "");
  26.         print "You had", numRight, "correct answers"
  27.         print "out of", numAsked, "tries."
  28.         if (numRight/numAsked > .6)
  29.             print "Not bad!"
  30.         else
  31.             print "Can we do some more?"
  32.     }
  33.